package com.work_attendance.user.service;

import com.work_attendance.common.utils.SecurityUtils;
import com.work_attendance.user.dao.UserMapper;
import com.work_attendance.user.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

@Transactional
@Service("userServiceimpl")
public class UserServiceimpl implements UserService{
    @Autowired
    private UserMapper userMapper;

    @Override
    public int createUser(User user) throws Exception {
        user.setPassword(SecurityUtils.encrptyPassword(user.getPassword()));
        return userMapper.insertSelective(user);
    }

    /**
     * @deprecated 根据用户名查询用户
     * @param username
     * @return
     */
    @Override
    public User findUserByUsername(String username) {
        User user=userMapper.selectByUsername(username);
        return user;
    }


}
